package com.linshidream.intrachat.simplenio.pipeline.handler;

import com.linshidream.intrachat.simplenio.pipeline.context.MiniHandlerContext;

/**
 * Created on 2025/8/19 18:03
 *
 * @author linshidream
 * @version 1.0.0
 * @description 入站处理器 ，处理顺序是从通道->业务
 */

public interface MiniChannelInboundHandler extends MiniChannelHandler {

    /**
     * 通道连接
     *
     * @param ctx
     */
    default void channelActive(MiniHandlerContext ctx) {
        ctx.fireChannelActive();
    }

    /**
     * 通道读取
     *
     * @param ctx
     * @param msg
     */
    default void channelRead(MiniHandlerContext ctx, Object msg) {
        ctx.fireChannelRead(msg);
    }

    /**
     * 通道关闭
     *
     * @param ctx
     */
    default void channelInactive(MiniHandlerContext ctx) {
        ctx.fireChannelInactive();
    }

    /**
     * 通道关闭
     *
     * @param ctx
     * @param cause
     */
    default void exceptionCaught(MiniHandlerContext ctx, Throwable cause) {
        ctx.fireExceptionCaught(cause);
    }


    default void userEventTriggered(MiniHandlerContext ctx, Object evt){
        ctx.fireUserEventTriggered(evt);
    }

}
